<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- <a href="http://www.baidu.com" target="_blank">提交</a> -->
    <form name="f1" action="http://www.baidu.com" target="_blank">
      <!-- Enter 提交 -->
      <input type="text" name="" id="" />
      <button type="submit">提交</button>
      <input type="submit" value="提交" />
    </form>
    <script>
      /*
            1. onsubmit form表单提交事件，必须要点击type=submit 按钮才能触发
            2. onsubmit 默认行为，跳转到action指定的地址
        */
      document.f1.onsubmit = function (e) {
        e.preventDefault();
        console.log("hello");
      };
      /* 
      不会触发onsubmit事件 ，无法阻止默认行为
      */
      // document.f1.submit();
    </script>
  </body>
</html>
